<?
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
header( 'Content-type: text/html; charset=windows-1251');

$bannerid = intval($_GET['b']);

include 'config/db.php';
if(!mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)) exit;
if(!mysql_select_db(DB_DATABASE)) exit;
mysql_query("SET NAMES cp1251");

function getRows($sql)
{
	$ret=Array();
	$res = mysql_query($sql);
	while($row = mysql_fetch_assoc($res))
	{
		$ret[] = $row;
	}
	mysql_free_result($res);
	return $ret;
}

$sites = getRows("select siteid,clicks,shows,title from codes,sites where bannerid=".$bannerid." and codes.siteid=sites.id");
?>


<table border="2">

<tr>
<td>Сайт:</td>
<td>Показы:</td>
<td>Клики:</td>
<td>CTR:</td>
</tr>

<? foreach($sites as $site) { ?>
<tr>
<td><?=$site['title']?></td>
<td><?=$site['shows']?></td>
<td><?=$site['clicks']?></td>
<? if($site['shows']>0) {?>
<td><?=100.0*($site['clicks']/$site['shows'])?>%</td>
<?} else {?>
<td></td>
<?}?>
</tr>
<? } ?>

</table>